<template>
  <div>
    <el-tree :data="categories" :props="defaultProps" @node-click="handleNodeClick"
             node-key="category_id"
    ></el-tree>
  </div>
</template>

<script>
export default {
  name: "BzMallCategoryTree",
  data(){
    return {
      categories:[],
      defaultProps: {
        children: 'children',
        label: 'categoryName',
        id:"category_id"
      }
    }
  },
  methods:{
    handleNodeClick(data){
      this.$emit("handleNodeClick",data.categoryId);
    }
  },
  created(){
    this.axios.get("/admin/bzCategory/tree")
      .then(resp=>{
        this.categories = resp.data.data;
      })
  }
}
</script>

<style scoped>
  .el-card{
    margin-top:20px
  }
  .el-row{
    margin: 10px 0;
  }
</style>
